package com.programmercarl.dp;

/**
 * https://leetcode.cn/problems/climbing-stairs/description/
 * 爬楼梯 AC
 *
 * @author yulongtian
 * @create 2025-02-09 10:43
 */
public class Test02 {
    public static void main(String[] args) {
        Test02 test02 = new Test02();
        System.out.println(test02.climbStairs(45));
    }

    public int climbStairs(int n) {
        if (n <= 2) {
            return n;
        }
        int a = 1;
        int b = 2;
        int c = 0;
        for (int i = 3; i <= n; i++) {
            c = a + b;
            a = b;
            b = c;
        }
        return c;
    }

}
